<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateMybankWithdrawRecord extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mybank_bill_record', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('shopId')->default(0)->comment("门店 ID");
            $table->unsignedTinyInteger('source')->default(1)->comment('来源 1美团 2 饿了么 3堂食');
            $table->unsignedInteger('transDate')->default(0)->comment('转账时间');
            $table->unsignedTinyInteger('transType')->default(0)->comment('转账类型 0 未知 1 提现支出 2 其他支出 3 收入');
            $table->string('displayTransType')->default(0)->comment('转账类型 显示文字');
            $table->string('transId')->default('')->comment('平台转账单号');
            $table->unsignedTinyInteger('transStatus')->default(0)->comment('转账状态 0 未知 1 成功 2 失败');
            $table->string('transDesc')->default('')->comment('转账描述');
            $table->unsignedInteger('billDate')->default(0)->comment('账单日');
            $table->integer('transAmount')->default(0)->comment('转账金额(分)');
            $table->integer('afterRemainingAmount')->default(0)->comment('转账后余额(分)');
            $table->string('remark')->default(1)->comment('备注');
            $table->tinyInteger("flagMark")->default(0)->comment("是否匹配 0:未匹配,1:已匹配");
            $table->tinyInteger("flagDivision")->default(0)->comment("是否分账 0:未分账,1:已分账");

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");

            $table->index('shopId', 'shopId_idx');
            $table->index('transId', 'transId_idx');
            $table->index('transDate', 'transDate_idx');

            $table->comment = '账单记录管理';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('mybank_bill_record');
    }
}
